//
//  ViewController.m
//  DefinedEqualHeightTB
//
//  Created by Ruoxin on 17/3/15.
//  Copyright © 2017年 Ruoxin. All rights reserved.
//

#import "ViewController.h"
#import "RXDefinedCell.h"
#import "RXDataModel.h"

static NSString *cellID = @"cellID";

@interface ViewController ()

@property (nonatomic, strong)NSArray *dataModel;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    if (!_dataModel) {
        
        NSArray *dataModelArr = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tgs" ofType:@"plist"]];
        NSMutableArray *temp = [NSMutableArray array];
        for (NSDictionary *dict in dataModelArr) {
            RXDataModel *dataModel = [RXDataModel dataWithDict:dict];
            [temp addObject:dataModel];
        }
        _dataModel = temp;
    }
    self.tableView.rowHeight = 100;
    [self.tableView registerClass:[RXDefinedCell class] forCellReuseIdentifier:cellID];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataModel.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    RXDefinedCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    
    // 设置数据
//    cell.textLabel.text = @"123";
     cell.dataModel = self.dataModel[indexPath.row];
    
    return cell;
}


@end
